package imy.virtual.touch.service;

import android.view.MotionEvent;

import java.util.HashMap;

import imy.virtual.touch.TouchCore;
import imy.virtual.touch.bean.GesturePoint;

public class EventSendThread implements Runnable {
    public MotionEvent event;

    public static HashMap<Integer, EventSendThread> mCache = new HashMap<>();

    public static EventSendThread obtain(MotionEvent event, int id) {
        EventSendThread eventSendThread = mCache.get(id);
        if (eventSendThread == null) {
            eventSendThread = new EventSendThread(event);
            mCache.put(id, eventSendThread);
        } else {
            eventSendThread.event = event;
        }
        return eventSendThread;
    }

    public EventSendThread(MotionEvent point) {
        event = point;
    }

    @Override
    public void run() {

        TouchCore.get().getInstrumentation().sendPointerSync(event);
    }
}
